package org.soft.xinyu.equipmentmanagement.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.soft.xinyu.equipmentmanagement.entity.WswMachine;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author vicente
 * @since 2021-11-22
 */
@Mapper
public interface WswMachineMapper extends BaseMapper<WswMachine> {

//    @Select("select * from wsw_machine")
    @Select("<script>"
            + "SELECT "
            + "a.id as 'id',a.create_date as 'createDate',a.content as 'content',"
            + "a.parent_id as 'parentId',a.first_comment_id as 'firstCommentId',"
            + "b.id as 'fromUser.id',b.realname as 'fromUser.realname',b.avatar as 'fromUser.avatar',"
            + "c.id as 'toUser.id',c.realname as 'toUser.realname',c.avatar as 'toUser.avatar' "
            + "FROM t_demand_comment a "
            + "LEFT JOIN t_user b ON b.id = a.from_uid "
            + "LEFT JOIN t_user c ON c.id = a.to_uid "
            + "WHERE a.demand_id = #{demandId} "
            + "ORDER BY a.create_date ASC "
            + "<if test='startNo!=null and pageSize != null '>"
            + "LIMIT #{startNo},#{pageSize}"
            + "</if>"
            + "</script>")
    List<WswMachine> getWswMachineListPage(@Param("pageNum") long pageNum,@Param("pageSize") long pageSize, String machineName);
}
